package es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions;

import java.sql.Connection;

import es.udc.fbellas.j2ee.util.exceptions.InstanceNotFoundException;
import es.udc.fbellas.j2ee.util.exceptions.InternalErrorException;
import es.udc.fbellas.j2ee.util.sql.TransactionalPlainAction;
import es.udc.emarketapp.emarket.model.purchase.dao.SQLPurchaseDAO;
import es.udc.emarketapp.emarket.model.purchase.dao.SQLPurchaseDAOFactory;

public class DeletePurchaseAction implements TransactionalPlainAction {

	private Long idPurchase;

	public DeletePurchaseAction(Long idPurchase) {

		this.idPurchase = idPurchase;

	}

	/**
	 * 
	 * @return <code>null</code>
	 */
	public Object execute(Connection connection)
			throws InstanceNotFoundException, InternalErrorException {

		SQLPurchaseDAO purchaseDAO = SQLPurchaseDAOFactory.getDAO();

		purchaseDAO.remove(connection, idPurchase);

		return null;

	}

}
